package com.huaxin.service;

import com.huaxin.entity.User;
import com.huaxin.mapper.UserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author Corday
 * @Create 2020/5/23 16:54
 */
@Service
public class UserSeviceImpl implements UserService {
    @Resource
    private UserMapper userMapper;

    //注册
    @Override
    public String addUser(User user) {
//        此处要校验是否有相同的用户
        String info = "用户名已存在或注册有误!";
        info = userMapper.insert(user) > 0 ? "注册成功!" : info;
        return info;
    }
//   声明一个查询用户名的方法

    //登录
    @Override
    public User queryUserByUsernmae(String username,String password) {
        return userMapper.selectByUsernameAndPassword(username,password);
    }
}
